//index.js
//获取应用实例
const app = getApp()
Page({
  data: {
    banner: [],
    dataRecommendPoetry:{},
    bannerHeight: Math.ceil(325.0 / 750.0 * getApp().screenWidth),
    bannerWidth: Math.ceil(getApp().screenWidth),
    txtRecommendPoetry : ""
  },
  onLoad: function (options) {
    this.loadRecommended();
  },
  loadRecommended: function () {
    var that = this;
    wx.showLoading({
      title: "加载中...",
    })
    wx.request({
      url: 'https://api.apiopen.top/recommendPoetry',
      header: {
        "Content-Type": "application/text"
      },
      method: 'POST',
      success: function (res) {
        
        console.log(res.data);
        var banner = [];
        var dataRecommendPoetry = res.data.result;
        var txtRecommendPoetry = "古诗随机推荐";
        banner.push("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556731797111&di=bbd5dc4dca025a26f7c3a9d11ad8fd8e&imgtype=0&src=http%3A%2F%2Fmat1.gtimg.com%2Fact3%2F2009-11-21%2F11%2Fe59ec235246db3dd5cdd56f29de4f7cd.jpg");
        banner.push("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556732067048&di=4f3a4915c8f4655c1e742f7adb1aab08&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F128e60f40e31db6fcf4858444d1515773968990719e19-qFAiqt_fw658");
        banner.push("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556711434635&di=c5cb57f9c02939f7fc015265dc16ca8f&imgtype=0&src=http%3A%2F%2Fimg2.ph.126.net%2FqZ9_DwJahiDsbhWoUJjL-A%3D%3D%2F6619235921072182286.jpg");
        banner.push("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556711434634&di=aab39231b79b8de47af23cfadfc7173d&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100809%2F2029588_231904076188_2.jpg");

        that.setData({
          banner: banner,
          dataRecommendPoetry: dataRecommendPoetry,
          txtRecommendPoetry : txtRecommendPoetry
        });
        wx.hideLoading();
      },
      fail: function (res) {
        console.log(res);
      },
      complete:function(res) {
        wx.hideLoading();
      }
    })
  },
  showSongCi: function () {
    wx.navigateTo({
    	url: "../list/list"
    });
    console.log("宋词");
  },
  showTangShi: function () {
    console.log("唐诗");
    wx.navigateTo({
      url: "../listTang/listTang"
    });
  },
  showTianQi: function () {
    console.log("天气");
    wx.navigateTo({
      url: "../weathers/weathers"
    });
  },
  showTuaiDi: function () {
    console.log("快递");
    // wx.navigateTo({
    //   url: "../van/van"
    // });
    wx.showModal({
      title: '待开发',
      content: '待开发',
    })
  },
  searchGuShi: function() {
    console.log("古诗搜索");
    wx.navigateTo({
      url: '../searchGuShi/searchGuShi',
    })
  },
  showGoods: function () {
    console.log("点击了轮播图");
    // wx.navigateTo({
    //   url: '../goods/detail/detail?objectId=5816e3b22e958a0054a1d711'
    // });
  }
})
